import React from "react";
import '../../index.css';

class Swiper extends React.Component{
  state ={
    bannerList: []
  }
  render(){
    return(
      <div className="swiper">
        <a href="#"><img src={this.state.bannerList.length > 0 && this.state.bannerList[0]['imgSrc']} alt="" /></a>
      </div>
    )
  }
  componentDidMount() {
    fetch('http://localhost:3000/home', {
      headers: {
        "Content-Type" : "application/json"
      }
    })
    .then(response => {
      return response.json()})
    .then(res => {

      this.setState({
        bannerList: res.banner
      })
      console.log(res, this.state)
    })
  }
};

export default Swiper;